
function y = difL2_MultiObj(w,t,P,X,Z,R,C)

y = zeros(t,1);
PZZ = calculatePHat_fixedW(w,t,X,Z,R,C);
for i = 1: t
    yy = 0;
    PP(:,:) = P(i,:,:);   
    PZZZ(:,:) = PZZ(i,:,:);
        
    for ii=1:R
        for jj=1:C
            yy = yy + myfunc(ii,jj,PP,PZZZ);
        end
    end
    
    y(i) = sqrt(yy);
    
end

end



function v = myfunc(ii,jj,P,PZ)

p = P(ii,jj);
pHat = PZ(ii,jj);


v = (p-pHat)^2;

end

